<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{$meta_title}</title>
    <meta name="nav_current" content="{$meta_title}">
    <link rel="stylesheet" href="__STATIC__/styles/vendors/bootstrap.min.css">
    <link rel="stylesheet" href="__STATIC__/styles/vendors/font-awesome.min.css">
    <link rel="stylesheet" href="__STATIC__/styles/layout.css">


    <link href="__STATIC__/styles/vendors/AdminLTE.min.css" rel="stylesheet">
    <link href="__STATIC__/styles/_all-skins.min.css" rel="stylesheet">

    <!-- 放置外层框架的样式 -->
    <link href="__STATIC__/styles/components.css" rel="stylesheet">
    <block name="style"></block>
</head>
<body class="skin-blue">
    <header class="main-header">
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <span class="navbar-brand">管理后台</span>
                </div>
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav navbar-right">
                        <gt name="unread_count" value="0">
                            <li class="unread_li"><a href="{:U('InfoManage/index', array('tab'=>2))}"><span class="badge bg-red">!</span></a></li>
                            <else/>
                            <li class="unread_li" style="display: none"><a href=""><span class="badge bg-red">!</span></a></li>
                        </gt>

                        <li><a href="javascript: void 0" id="setting">设置</a></li>
                        <li><a href="{:U('Public/logout')}">退出</a></li>
                    </ul>
                    <input type="hidden" name="chat_id" value="{:session('user_auth.chat_id')}">
                </div>
            </div>
        </nav>
    </header>
    <div class="container-fluid">
        <div class="row">
            <aside class="side-bar main-sidebar" id="left">
                <ul class="sidebar-menu ">
                    <volist name="__MENU__" id="menu">
                        <li class="{$menu.class|default=''}">
                            <a href="{$menu.url|U}"><i class="fa fa-circle-o"></i>{$menu.title}</a>
                        </li>
                    </volist>
                </ul>
            </aside>
            <div class="content-wrapper" id="right">
                <block name="content">

                </block>
                <!--<h1 id="greet">欢迎使用</h1>-->
            </div>
            <footer class="main-footer">
                <div class="pull-right hidden-xs">
                    <b>版本</b> 1.0
                </div>
                <strong>Copyright © 2016</strong>
            </footer>
        </div>
    </div>
    <div class="modal fade" id="pwd_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
        <div class="modal-dialog modal-sm" role="document">
            <form id="resetPwdForm" class="modal-content" action="{:U('resetPassword')}" method="post">
                <div class="modal-body">
                    <div class="control-group row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 left">
                            <label class="control-label" for="origin_pwd">原始密码:</label>
                        </div>
                        <div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 right">
                            <div class="controls">
                                <input type="password" class="form-control" id="origin_pwd" name="origin_pwd">
                            </div>
                        </div>
                        <span class="marked marked-error glyphicon glyphicon-remove-circle"></span>
                    </div>
                    <div class="control-group row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 left">
                            <label class="control-label" for="new_pwd">新密码:</label>
                        </div>
                        <div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 right">
                            <div class="controls">
                                <input type="password" class="form-control" id="new_pwd" name="new_pwd">
                            </div>
                        </div>
                        <span class="marked marked-error glyphicon glyphicon-remove-circle"></span>
                    </div>
                    <div class="control-group row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 left">
                            <label class="control-label" for="repeat">重复输入:</label>
                        </div>
                        <div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 right">
                            <div class="controls">
                                <input type="password" class="form-control" id="repeat" name="repeat">
                            </div>
                        </div>
                        <span class="marked marked-success glyphicon glyphicon-ok-circle"></span>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary btn-flat">确定</button>
                    <button type="button" class="btn btn-default btn-flat" data-dismiss="modal">取消</button>
                </div>
            </form>
        </div>
    </div>
    <script src="__STATIC__/scripts/vendors/jquery-1.12.4.js"></script>
    <script src="__STATIC__/scripts/vendors/bootstrap.min.js"></script>
    <script src="__STATIC__/scripts/layout.js"></script>
    <script src="__STATIC__/plugins/layer/layer.js"></script>
    <script src="__STATIC__/plugins/jvalidate/jquery.validate.min.js"></script>
    <script>
        $(function () {
            $('#pwd_modal').on('show.bs.modal', function () {
                $(this).find('#resetPwdForm')[0].reset();
            });
            $('#resetPwdForm').validate({
                debug:true,
                submitHandler:function (form) {
                    var url = $(form).prop('action');
                    var postData = $(form).serialize();
                    $.post(url,postData, function(data){
                        if(data.status == 1){
                            layer.msg('修改成功');
                            $('#pwd_modal').modal('hide');
                        }else{
                            layer.msg(data.msg);
                        }
                    });
                },
                rules:{
                    origin_pwd:"required",
                    new_pwd:"required",
                    repeat:{
                        required:true,
                        equalTo:'#new_pwd'
                    }
                },
                messages:{
                    origin_pwd:"请输入原始密码",
                    new_pwd:"请输入新密码",
                    repeat:{
                        required:'请再次输入新密码',
                        equalTo:'两次输入的密码不一致'
                    }
                }

            })
        })
    </script>

    <block name="im_script">
        <script>
            var chatSocket;
            var chat_id = $('input[name=chat_id]').val();

            function initIM(){
                chatSocket = new WebSocket("{:C('IM_URL')}");
                chatSocket.onopen = function(event){
                    var msg = new Object();
                    msg.cmd = 0;
                    msg.userid = chat_id;
                    chatSocket.send(JSON.stringify(msg));
                };

                chatSocket.onmessage = function(event){
                    var msg = JSON.parse(event.data);
                    if(msg.cmd == 2){
                        if(msg.type == 1){
                            $('.unread_li').show();
                        }
                    }
                    console.log(event.data);
                }
            }

            $(function () {
                initIM();
            })


        </script>
    </block>
    <block name="script">







    </block>
</body>
</html>